// Time:  O(n)
// Space: O(1)

#include <vector>

using namespace std;

class Solution {
public:
    int repeatedNTimes(vector<int>& nums) {
        for (int i = 2; i < nums.size(); ++i) {
            if (nums[i - 1] == nums[i] || nums[i - 2] == nums[i])  {
                return nums[i];
            }
        }
        return nums[0];
    }
};
